<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //父类 手机
        function phone(brand, price) {
            this.brand = brand;
            this.price = price;
        }
        phone.prototype.call = function() {
            console.log('我可以打电话!');
        }

        //子类 智能手机
        function smartPhone(brand, price, color, size) {
            phone.call(this, brand, price); //继承父类的brand和price属性
            this.color = color;
            this.size = size;
        }
        // 设置子级构造函数的原型
        smartPhone.prototype = new phone; //继承父类的方法
        smartPhone.prototype.constructor = smartPhone;
        //声明子类的方法
        smartPhone.prototype.photo = function() {
            console.log('我可以拍照!');
        }
        smartPhone.prototype.playGame = function() {
            console.log('我可以玩游戏！');
        }
        let chuizi = new smartPhone('锤子', 1999, '黑色', '5.5inch');
        console.log(chuizi);
        console.log(chuizi.call);
    </script>
</body>

</html>